package com.zz.ecommerce.declareManage.exportB2BDeclare.orderManageQdc;

import com.alibaba.fastjson.JSONObject;
import com.zz.ecommerce.common.GridRequest;
import com.zz.ecommerce.common.GridResult;
import com.zz.ecommerce.common.bean.qdc.db.TGoodsListQdc;
import com.zz.ecommerce.common.bean.qdc.db.TOrderHeadQdc;
import com.zz.ecommerce.common.bean.qdc.db.TWaybillListQdc;
import com.zz.ecommerce.common.constants.DictConstants;
import com.zz.ecommerce.common.constants.TableConstants;
import com.zz.ecommerce.declareManage.common.dao.QdcOrderHeadDao;
import com.zz.ecommerce.declareManage.common.service.QdcOrderService;
import com.zz.ecommerce.utils.SessionUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by steven on 2016/3/28.
 */
@Controller
@RequestMapping("/exportB2B/orderManageQdc")
public class QdcEB2bOrderController {

    @Autowired
    private QdcOrderHeadDao orderHeadDao;

    @Autowired
    private QdcOrderService orderService;

    /**
     * 初始化订单管理页面
     *
     * @return
     */
    @RequestMapping("/init")
    public String init() {
        return "declareManage/exportB2BDeclare/orderManageQdc/index";
    }

    /**
     * 初始化订单导入页面
     *
     * @return
     */
    @RequestMapping("/orderImportQdc")
    public String orderImportQdc() {
        return "declareManage/exportB2BDeclare/orderImportQdc/index";
    }

    /**
     * 订单管理页面列表数据
     *
     * @param orderHead
     * @param request
     * @param session
     * @return
     */
    @RequestMapping("/queryOrderList")
    @ResponseBody
    public GridResult queryOrderList(TOrderHeadQdc orderHead, GridRequest request, HttpSession session) {
        orderHead.setOrgId(SessionUtil.getOrganizationId(session));
        orderHead.setIeFlag(DictConstants.EXPORT);
        orderHead.setBusinessType(DictConstants.B2B);

        return orderService.queryOrderList(request, orderHead);
    }

    /**
     * 订单导入页面列表数据
     *
     * @param orderHead
     * @param request
     * @param session
     * @return
     */
    @RequestMapping("/queryOrderImportList")
    @ResponseBody
    public GridResult queryOrderImportList(TOrderHeadQdc orderHead, GridRequest request, HttpSession session) {
        orderHead.setOrgId(SessionUtil.getOrganizationId(session));
        orderHead.setIeFlag(DictConstants.EXPORT);
        orderHead.setBusinessType(DictConstants.B2B);
        orderHead.setIfCreate("0");
        return orderService.queryOrderList(request, orderHead);
    }
}
